<?php
class ListShow_Model_Things extends Zend_Db_Table{
	protected $_name = 'things';
	protected $_primary = 'thing_id';

	
	public function getAllThingsbyType($type)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getAllThingsbyType/type/".$type);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}	
	
	public function getTypedThingsByCategory($category,$type)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getTypedThingsByCategory/type/".$type."/category/".$category);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];	
		return $data;
	}
	
	
	public function getThingsInPage($type,$page,$offset)
	{// co dung
		
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getThingsInPage/type/".$type."/page/".$page."/offset/".$offset);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	
	public function getThingsByCategoryInPage($category,$type,$page,$offset)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getThingsByCategoryInPage/category/".$category."/type/".$type."/page/".$page."/offset/".$offset);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	
	public function getTypedThingsByParentCategory($category,$type)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getTypedThingsByParentCategory/category/".$category."/type/".$type);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	
	public function getThingsByParentCategoryInPage($category,$type,$page,$offset)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/things/route/getThingsByParentCategoryInPage/category/".$category."/type/".$type."/page/".$page."/offset/".$offset);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	
}
?>